package team.szm.scd.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.web.bind.annotation.*;
import team.szm.scd.database.dto.RequestWrapper;
import team.szm.scd.database.dto.Result;
import team.szm.scd.database.entity.InspectionType;
import team.szm.scd.service.interfaces.IInspectionService;
import team.szm.scd.service.interfaces.ILoginService;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("/inspection")
public class InspectionController {
    @Resource
    IInspectionService service;
    @Resource
    ILoginService loginService;

    @PostMapping("search_type")
    @ResponseBody
    public Result<List<InspectionType>>
    searchInspectionType(@RequestBody RequestWrapper<String> name, HttpSession session) {
        if (loginService.noDoctorLogin(session)) {
            return Result.needLogin();
        }
        return Result.success(service.searchInspectionType(name.value));
    }
}
